package com.cyandpos.pad.refund.model;

import android.text.TextUtils;

import com.cyandpos.pad.common.ManagerCardManager.MangerCardData;
import com.cyandpos.pad.common.commondata.BaseResponse;
import com.cyandpos.pad.common.netmanager.PosHttpManager;
import com.cyandpos.pad.http.OkHttpUtils;
import com.cyandpos.pad.refund.contract.RefundYZContract;
import com.google.gson.JsonObject;

public class RefundYZModelImpl implements RefundYZContract.Model{
    @Override
    public void getData(String managerNo,final OnCompleteListener completeListener) {
        PosHttpManager.managerYZHttpEexcute(null,managerNo, new OkHttpUtils.ResultCallback() {
            @Override
            public void onSuccess(JsonObject response) {
                BaseResponse<MangerCardData> baseResponse = BaseResponse.fromJson(response.toString(), MangerCardData.class);
                if(baseResponse.getCode().equals("0")){
                    completeListener.onSuccess(baseResponse.getData());
                }else{
                    if (TextUtils.isEmpty(baseResponse.getTips())){
                        completeListener.onFailure(baseResponse.getMsg());
                    }else {
                        completeListener.onFailure(baseResponse.getTips());
                    }
                }

            }

            @Override
            public void onFailure(String msg) {
                completeListener.onFailure(msg);
            }
        });
    }
}
